package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.SaveTeachPlanDto;
import com.xuecheng.content.model.dto.TeachPlanDto;
import com.xuecheng.content.service.TeachplanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 课程计划管理相关的接口
 *
 * @author jiang zhongxun
 * @create 2023-03-12 16:59
 */
@Api(value = "课程计划管理相关的接口", tags = "课程计划管理相关的接口")
@RestController
public class TeachPlanController {

    @Autowired
    TeachplanService teachplanService;

    /**
     * 查询课程计划树形结构
     *
     * @param courseId 课程id
     * @return {@link List}<{@link TeachPlanDto}>
     */
    @ApiOperation("查询课程计划树形结构接口")
    @ApiImplicitParam(value = "courseId", name = "课程ID", required = true, dataType = "Long", paramType = "path")
    @GetMapping("/teachPlan/{courseId}/treeNodes")
    public List<TeachPlanDto> getTreeNodes(@PathVariable Long courseId) {
        return teachplanService.findTeachPlanTree(courseId);
    }

    /**
     * 新增/保存/修改课程计划
     *
     * @param saveTeachPlanDto 保存、修改课程计划 DTO
     */
    @ApiOperation("课程计划创建或修改接口")
    @PostMapping("/teachplan")
    public void saveTeachPlan(@RequestBody SaveTeachPlanDto saveTeachPlanDto) {
        teachplanService.saveTeachPlan(saveTeachPlanDto);
    }

}
